<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML >
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>添加notice</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	
    <%@include file="/pages/head/head.jsp" %>
     
  </head>
  
  <body>
   <div id="wrapper">
        <!-- 左边菜单 -->
         <%@include file="/pages/left/leftmenu.jsp" %>

        <div id="page-wrapper" class="gray-bg dashbard-1">
             <!-- 引入top菜单 -->
              <%@include file="/pages/left/topmenu.jsp" %>
            
            <!--左边内容开发，开始  -->
              <div class="row wrapper border-bottom white-bg page-heading">
                <div class="col-lg-10">
                    <h2>校园公告</h2>
                    <ol class="breadcrumb">
                        <li>
                            <a href="index.html">主页</a>
                        </li>
                        <li>
                            <a>校园公告</a>
                        </li>
                        <li>
                            <strong>添加校园公告</strong>
                        </li>
                    </ol>
                </div>
                <div class="col-lg-2">

                </div>
            </div>
            <div class="wrapper wrapper-content animated fadeInRight">
                
                <div class="row">
                    <div class="col-lg-14">
                        <div class="ibox float-e-margins">
                            <div class="ibox-title">
                                <h5>添加校园公告</h5>
                                <div class="ibox-tools">
                                    <a class="collapse-link">
                                        <i class="fa fa-chevron-up"></i>
                                    </a>
                                </div>
                            </div>
                            <div class="ibox-content">
                                <form class="form-horizontal m-t" id="notice">
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">发布人：</label>
                                        <div class="col-sm-8">
                                            <input id="userName" name="userName"  value="${notice.userName }" maxlength="30"  class="form-control" type="text">
                                            <input id="no_id" name="no_id" value="${notice.no_id }" maxlength="30"  class="form-control" type="hidden">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">公告标题：</label>
                                        <div class="col-sm-8">
                                            <input id="title" name="title" maxlength="30"  value="${notice.title }"  class="form-control" type="text">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">公告类型：</label>
                                        <div class="col-sm-8">
                                            <select class="form-control m-b" name="type">
                                                <option value="2" <c:if test="${notice.type eq '2' }">selected</c:if>  >事件</option>
                                                <option value="1" <c:if test="${notice.type eq '1' }">selected</c:if> >通知</option>
                                            </select>
                                        </div>
                                    </div>
                                     <div class="form-group" id="data_1">
                                    <label class="col-sm-3 control-label">发布时间：</label>
                                    <div class="input-group date " style="width: 715px;padding-left: 14px;">
                                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                                        <input type="text" class="form-control" name="time" value="${notice.time }">
                                    </div>
                                </div>
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">照片名称：</label>
                                        <div class="col-sm-8">
                                            <input id="photoName" name="photoName" value="${notice.photoName }" class="form-control" type="text" aria-required="true" aria-invalid="true" class="error">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">照片地址：</label>
                                        <div class="col-sm-8">
                                            <input id="URL" name="URL" class="form-control" value="${notice.URL }" type="url">
                                        </div>
                                    </div> 
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">公告内容：</label>
                                        <div class="col-sm-8">
                                <textarea id="editor" name="content" placeholder="这里输入公告内容" autofocus>
                                ${notice.content}
                                </textarea>
                            </div>
                                    </div>
                                    <div class="form-group">
                                        <div class="col-sm-8 col-sm-offset-3">
                                            <button class="btn btn-primary" id="savenotice" type="button">提交</button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>

            </div>
            <div class="footer">
                <div class="pull-right">
                    By：<a href="" target="_blank">zihan's blog</a>
                </div>
                <div>
                    <strong>Copyright</strong> H+ &copy; 2014
                </div>
            </div>

        </div>
    </div>
     <%@include file="/pages/head/foot.jsp" %>
    
     
    <script>
        $(document).ready(function () {
        	//编辑器
            var editor = new Simditor({
                textarea: $('#editor'),
                defaultImage: 'img/a9.jpg'
            });
        	//date
            $('#data_1 .input-group.date').datepicker({
                todayBtn: "linked",
                keyboardNavigation: false,
                forceParse: false,
                calendarWeeks: true,
                autoclose: true
            });
        	
        	$("#savenotice").click(function(){
        		var url="${pageContext.request.contextPath}/notice/addNotice.do";
            	var param=$("#notice").serialize();
            	$.post(url,param,function(data){
            		if(data=="succ"){
            			alert("保存成功");
            			location.reload();
            		}else{
            			alert("保存失败,请再次保存！");
            		}
            	});
        	});
        	
        	
        	
        });
    </script>
  </body>
</html>